package cn.openea.perpartner.meily.web.mapper;

import cn.openea.perpartner.meily.web.entity.ProvideSamples;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 
 * 
 * @author ysk
 * @email zane_ysk@qq.com
 * @date 2023-03-27 11:37:04
 */
@Mapper
public interface ProvideSamplesMapper extends BaseMapper<ProvideSamples> {

    /**
     * 获取需要结束的样品任务
     * @return
     */
    @Select("select * from meily_provide_samples where `status` = '1' HAVING datediff(DATE_FORMAT(end_time, '%Y-%m-%d %H:%m:%s'), now()) <= 0 ORDER BY end_time")
    List<ProvideSamples> getNextEndAWeekTaskList();

    /**
     * 获取已结束一周的样品任务
     * @return
     */
    @Select("select * from meily_provide_samples where `status` = '0' and finish_time <> '' HAVING timestampdiff(DAY, now(), date_add(DATE_FORMAT(finish_time, '%Y-%m-%d %H:%m:%s'), interval 7 day)) < 0 ORDER BY finish_time")
    List<ProvideSamples> getEndAWeekTaskList();

    /**
     * 获取已结束一个月的样品任务
     */
    @Select("select * from meily_provide_samples where `status` = '0' and finish_time <> '' and DATE_FORMAT(date_add(create_time, interval 1 month), '%Y-%m-%d') = DATE_FORMAT(now(), '%Y-%m-%d') ORDER BY create_time")
    List<ProvideSamples> getEndAMonthTaskList();

}
